{php include pubTemplate("header")}

<div class="container">

    {template menu}

    <div class="row">
        <div class="col-md-8">


            <div class="card">
                <div class="card-body">



                    {if tsIntval($TS_USER['userid']) >0 && tsIntval($TS_USER['userid']) != $strUser['userid']}
                    <div class="guest">
                        <img class="rounded-circle" src="{SITE_URL}public/images/user_large.jpg" />
                        <form method="post" action="{SITE_URL}index.php?app=user&ac=guestbook&ts=do">
                            <textarea class="form-control" name="content"></textarea>

                            <input type="hidden" name="touserid" value="{$strUser['userid']}" />
                            <input type="hidden" name="token" value="{$_SESSION['token']}" />

                            <div class="pd100">
                                <button class="btn btn-sm btn-info" type="submit">添加留言</button>
                            </div>



                        </form>
                    </div>
                    {/if}
                    <div class="clear"></div>

                    <!--回复-->
                    <div id="reguest" style="display:none;">
                        <form method="post" action="{SITE_URL}index.php?app=user&ac=guestbook&ts=redo">
                            <textarea class="form-control" name="content"></textarea>

                            <input id="touserid" type="hidden" name="touserid" value="0" />
                            <input id="reid" type="hidden" name="reid" value="0" />

                            <div class="pd100">
                                <button class="btn btn-sm btn-info" type="submit">回复</button>
                                <a class="btn btn-sm btn-outline-secondary" href="javascript:void('0')" onclick="reguest()">取消</a>
                            </div>

                        </form>
                    </div>


                    {if $arrGuestList}
                    <div class="glist">
                        <ul>

                            {loop $arrGuestList $key $item}
                            <li>
                                <a href="{tsUrl('user','space',array('id'=>$item['userid']))}">
                                    <img src="{$item['user']['face']}" width="36" height="36" class="rounded-circle" />
                                </a>
                                <div class="content">
                                    <p class="c9 fs12"><a href="{tsUrl('user','space',array('id'=>$item['userid']))}">{$item['user']['username']}</a> {$item['addtime']}</p>
                                    <div>{$item['content']}</div>
                                    {if $item['reply']}
                                    <div class="bg-light p-2 text-secondary rounded">回复：{$item['reply']['content']}</div>
                                    {/if}


                                    <p class="text-right fs12">

                                        {if tsIntval($TS_USER['userid']) == $strUser['userid']}
                                        <a href="#reguest" onclick="reguest('{$item['userid']}','{$item['id']}','{$item['user']['username']}')"><i class="bi bi-reply"></i> 回复</a>
                                        <a class="ml-2" href="{tsUrl('user','guestbook',array('ts'=>'delete','gbid'=>$item['id']))}" onclick="return confirm('确定删除?')"><i class="bi bi-trash"></i> 删除</a>
                                        {/if}
                                    </p>
                                    <!--回复留言-->

                                </div>
                            </li>
                            {/loop}
                        </ul>
                    </div>

                    <div class="clear"></div>
                    <div class="page">{$pageUrl}</div>

                    {else}
                    <div class="text-black-50">暂无留言！</div>
                    {/if}

                </div>
            </div>
        </div>

        <div class="col-md-4">
            {template userinfo}
        </div>

    </div>
</div>
{php include pubTemplate("footer")}